package org.qs.webservice.util;

import java.util.Properties;

import javax.mail.Message.RecipientType;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
 
public class SendmailUtil {
    public static boolean sendMail(String subject,String context,String email){
		try {
			String userName = "service@iqinshu.com";  
			// 下面是邮箱的密码  
			String password = "QinshuRg2fTRE$JH3";  
			String host = "smtp.exmail.qq.com";  
			String protocal = "smtp";  
			//String to = "15869155962@139.com";  
			Properties props = new Properties();  
			props.put("mail.smtp.auth", "true");  
			Session session = Session.getDefaultInstance(props);  
			MimeMessage message = new MimeMessage(session);  
			   
			message.setRecipients(RecipientType.TO, email);
				
			message.setFrom(new InternetAddress(userName));  
			message.setSubject(subject);  
			message.setContent(context, "text/html;charset=UTF-8");  
			Transport transport = session.getTransport(protocal);  
			transport.connect(host, userName, password);  
			transport.sendMessage(message, message.getAllRecipients()); 
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		} 
		return false;
	}
     
   
    
}